import { Service } from 'egg';

export default class Sys extends Service {
  public async medicalList() {
    const list = await this.ctx.model.MedicalField.findAll({
      attributes: [
        'uuid',
        'name',
      ]
    });

    return list;
  }

  public async companyTypeList() {
    const list = await this.ctx.model.CompanyType.findAll({
      attributes: [
        'uuid',
        'name',
      ]
    });

    return list;
  }

  public async mainBusinessList() {
    const list = await this.ctx.model.MainBusiness.findAll({
      attributes: [
        'uuid',
        'name',
      ]
    });

    return list;
  }

  public async optionList() {
    const [
      medicalOptionList,
      typeList,
      businessOptionList
    ] = await Promise.all([
      this.medicalList(),
      this.companyTypeList(),
      this.mainBusinessList()
    ]);

    return {
      medicalOptionList,
      typeList,
      businessOptionList
    };
  }

}

